-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix: Duplicate review tax code page shows no options across workspaces #81079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix: Duplicate review tax code page shows no options across workspaces #81079
Conversation
|
@hungvu193 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Use threadReportID directly in ReviewTaxCode (consistent with other review pages) and derive the policy from the kept transaction's workspace for correct tax lookups. Merge thread transaction's duplicate list in TransactionPreview to ensure cross-workspace duplicates are fully represented in the review flow.
6f1ece5 to
f907dc9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6f1ece5e97
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const navigateToReviewFields = useCallback(() => { | ||
| Navigation.navigate(getReviewNavigationRoute(Navigation.getActiveRoute(), route.params?.threadReportID, transaction, duplicates, policyCategories, transactionReport)); | ||
| }, [route.params?.threadReportID, transaction, duplicates, policyCategories, transactionReport]); | ||
| const allDups = [...duplicates, ...(threadDupTxns ?? [])]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filter thread duplicates before merging
duplicates has already been filtered with removeSettledAndApprovedTransactions, but threadDupTxns is appended without that filter. If the thread transaction’s violations include a duplicate that is settled/approved (e.g., one duplicate was already approved), allDups will reintroduce it and getReviewNavigationRoute will store it in reviewDuplicates.duplicates. That can cause the review flow to consider non‑reviewable transactions and pass settled/approved IDs into the merge params. Consider filtering/deduping threadDupTxns (or the merged list) the same way before navigation.
Useful? React with 👍 / 👎.
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
hungvu193
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this PR ready for review? Could you complete the author checklist please? 👀
| const threadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${route.params?.threadReportID}`]; | ||
| const threadViolations = useTransactionViolations(getTransactionID(threadReport)); | ||
| const [threadDuplicates] = useTransactionsByID( | ||
| useMemo(() => threadViolations?.find((v) => v.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION)?.data?.duplicates ?? [], [threadViolations]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this file is compiled with react-compiler, we might not need the useMemo here.
| const personalDetails = usePersonalDetails(); | ||
|
|
||
| // Load thread transaction's complete duplicate list for cross-workspace comparison | ||
| const threadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${route.params?.threadReportID}`]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const threadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${route.params?.threadReportID}`]; | |
| const threadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(route.params?.threadReportID)}`]; |
| const [reviewDuplicates] = useOnyx(ONYXKEYS.REVIEW_DUPLICATES, {canBeMissing: true}); | ||
| const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reviewDuplicates?.reportID ?? route.params.threadReportID}`, {canBeMissing: true}); | ||
| const policy = usePolicy(report?.policyID); | ||
| const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${route.params.threadReportID}`, {canBeMissing: true}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${route.params.threadReportID}`, {canBeMissing: true}); | |
| const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(route.params.threadReportID)}`, {canBeMissing: true}); |
Explanation of Change
When reviewing duplicate expenses that span two workspaces with different feature configurations (e.g., Workspace A has taxes/categories/tags enabled, Workspace B does not), the review flow had multiple failures:
ReviewTaxCode.tsxline 27 usedreviewDuplicates?.reportIDas a fallback, loading the kept transaction's report instead of the thread report. This caused all downstream data (transaction, violations, duplicate IDs) to be derived from the wrong source.policywas still derived from the thread report's workspace (which may not have taxes enabled). Tax lookups (getTaxByID,getDefaultTaxCode,getTaxValue) need to use the kept transaction's workspace policy.TransactionPreviewnow also loads the thread transaction's duplicate list and merges both lists before callinggetReviewNavigationRoute, ensuring all duplicates are represented.Changes:
ReviewTaxCode.tsx: Useroute.params.threadReportIDdirectly (consistent with all other review pages). MoveusePolicyto derive fromreviewDuplicatesReport?.policyID(the kept transaction's workspace) instead of the thread report's workspace.TransactionPreview/index.tsx: Load the thread transaction's duplicate list via its violations and merge with the kept transaction's duplicates in the navigation callback, ensuring complete cross-workspace coverage.Fixed Issues
$ #80476
PROPOSAL: #80476 (comment)
Tests
Preconditions:
Offline tests
The duplicate review flow requires online connectivity to load transaction violations and policy data. No offline-specific changes were made.
QA Steps
Same as tests above. Ensure two workspaces exist with different feature configurations (one with taxes/categories/tags enabled, one without) and three duplicate transactions spanning both workspaces.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)Avataris modified, I verified thatAvataris working as expected in all cases)Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari